package com.luych.toolbox.docker.service.sdk.image.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class DockerImageInspectResult {

    @JsonProperty("RepoDigests")
    private List<String> repoDigests;

    @JsonProperty("Comment")
    private String comment;

    @JsonProperty("VirtualSize")
    private Long virtualSize;

    @JsonProperty("Os")
    private String os;

    @JsonProperty("Architecture")
    private String architecture;

    @JsonProperty("Parent")
    private String parent;

    @JsonProperty("Size")
    private Long size;

    @JsonProperty("Config")
    private Config config;

    @JsonProperty("GraphDriver")
    private GraphDriver graphDriver;

    @JsonProperty("Created")
    private String created;

    @JsonProperty("ContainerConfig")
    private ContainerConfig containerConfig;

    @JsonProperty("Container")
    private String container;

    @JsonProperty("RootFS")
    private RootFS rootFS;

    @JsonProperty("DockerVersion")
    private String dockerVersion;

    @JsonProperty("RepoTags")
    private List<String> repoTags;

    @JsonProperty("Author")
    private String author;

    @JsonProperty("Id")
    private String id;

    public List<String> getRepoDigests() {
        return repoDigests;
    }

    public void setRepoDigests(List<String> repoDigests) {
        this.repoDigests = repoDigests;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Long getVirtualSize() {
        return virtualSize;
    }

    public void setVirtualSize(Long virtualSize) {
        this.virtualSize = virtualSize;
    }

    public String getOs() {
        return os;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String getArchitecture() {
        return architecture;
    }

    public void setArchitecture(String architecture) {
        this.architecture = architecture;
    }

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public Config getConfig() {
        return config;
    }

    public void setConfig(Config config) {
        this.config = config;
    }

    public GraphDriver getGraphDriver() {
        return graphDriver;
    }

    public void setGraphDriver(GraphDriver graphDriver) {
        this.graphDriver = graphDriver;
    }

    public String getCreated() {
        return created;
    }

    public Date getCreatedDate() {
        if (created == null) return null;
        ZonedDateTime zonedDateTime = ZonedDateTime.parse(created, DateTimeFormatter.ISO_DATE_TIME);
        return Date.from(zonedDateTime.toInstant());
    }

    public void setCreated(String created) {
        this.created = created;
    }

    public ContainerConfig getContainerConfig() {
        return containerConfig;
    }

    public void setContainerConfig(ContainerConfig containerConfig) {
        this.containerConfig = containerConfig;
    }

    public String getContainer() {
        return container;
    }

    public void setContainer(String container) {
        this.container = container;
    }

    public RootFS getRootFS() {
        return rootFS;
    }

    public void setRootFS(RootFS rootFS) {
        this.rootFS = rootFS;
    }

    public String getDockerVersion() {
        return dockerVersion;
    }

    public void setDockerVersion(String dockerVersion) {
        this.dockerVersion = dockerVersion;
    }

    public List<String> getRepoTags() {
        return repoTags;
    }

    public void setRepoTags(List<String> repoTags) {
        this.repoTags = repoTags;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public static class GraphDriver {

        @JsonProperty("Data")
        private Data data;

        @JsonProperty("Name")
        private String name;

        public Data getData() {
            return data;
        }

        public void setData(Data data) {
            this.data = data;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static class Data {

        }
    }

    public static class Config {

        @JsonProperty("User")
        private String user;

        @JsonProperty("AttachStderr")
        private Boolean attachStderr;

        @JsonProperty("PublishService")
        private String publishService;

        @JsonProperty("Hostname")
        private String hostname;

        @JsonProperty("OpenStdin")
        private Boolean openStdin;

        @JsonProperty("Labels")
        private Map<String, String> labels;

        @JsonProperty("Image")
        private String image;

        @JsonProperty("NetworkDisabled")
        private Boolean networkDisabled;

        @JsonProperty("Env")
        private List<String> env;

        @JsonProperty("MacAddress")
        private String macAddress;

        @JsonProperty("StdinOnce")
        private Boolean stdinOnce;

        @JsonProperty("AttachStdout")
        private Boolean attachStdout;

        @JsonProperty("WorkingDir")
        private String workingDir;

        @JsonProperty("OnBuild")
        private List<Object> onBuild;

        @JsonProperty("AttachStdin")
        private Boolean attachStdin;

        @JsonProperty("Domainname")
        private String domainname;

        @JsonProperty("Tty")
        private Boolean tty;

        @JsonProperty("Cmd")
        private List<String> cmd;

        @JsonProperty("Entrypoint")
        private List<String> entrypoint;

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public Boolean getAttachStderr() {
            return attachStderr;
        }

        public void setAttachStderr(Boolean attachStderr) {
            this.attachStderr = attachStderr;
        }

        public String getPublishService() {
            return publishService;
        }

        public void setPublishService(String publishService) {
            this.publishService = publishService;
        }

        public String getHostname() {
            return hostname;
        }

        public void setHostname(String hostname) {
            this.hostname = hostname;
        }

        public Boolean getOpenStdin() {
            return openStdin;
        }

        public void setOpenStdin(Boolean openStdin) {
            this.openStdin = openStdin;
        }

        public Map<String, String> getLabels() {
            return labels;
        }

        public void setLabels(Map<String, String> labels) {
            this.labels = labels;
        }

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }

        public Boolean getNetworkDisabled() {
            return networkDisabled;
        }

        public void setNetworkDisabled(Boolean networkDisabled) {
            this.networkDisabled = networkDisabled;
        }

        public List<String> getEnv() {
            return env;
        }

        public void setEnv(List<String> env) {
            this.env = env;
        }

        public String getMacAddress() {
            return macAddress;
        }

        public void setMacAddress(String macAddress) {
            this.macAddress = macAddress;
        }

        public Boolean getStdinOnce() {
            return stdinOnce;
        }

        public void setStdinOnce(Boolean stdinOnce) {
            this.stdinOnce = stdinOnce;
        }

        public Boolean getAttachStdout() {
            return attachStdout;
        }

        public void setAttachStdout(Boolean attachStdout) {
            this.attachStdout = attachStdout;
        }

        public String getWorkingDir() {
            return workingDir;
        }

        public void setWorkingDir(String workingDir) {
            this.workingDir = workingDir;
        }

        public List<Object> getOnBuild() {
            return onBuild;
        }

        public void setOnBuild(List<Object> onBuild) {
            this.onBuild = onBuild;
        }

        public Boolean getAttachStdin() {
            return attachStdin;
        }

        public void setAttachStdin(Boolean attachStdin) {
            this.attachStdin = attachStdin;
        }

        public String getDomainname() {
            return domainname;
        }

        public void setDomainname(String domainname) {
            this.domainname = domainname;
        }

        public Boolean getTty() {
            return tty;
        }

        public void setTty(Boolean tty) {
            this.tty = tty;
        }

        public List<String> getCmd() {
            return cmd;
        }

        public void setCmd(List<String> cmd) {
            this.cmd = cmd;
        }

        public List<String> getEntrypoint() {
            return entrypoint;
        }

        public void setEntrypoint(List<String> entrypoint) {
            this.entrypoint = entrypoint;
        }
    }

    public static class ContainerConfig {

        @JsonProperty("User")
        private String user;

        @JsonProperty("AttachStderr")
        private Boolean attachStderr;

        @JsonProperty("PublishService")
        private String publishService;

        @JsonProperty("Hostname")
        private String hostname;

        @JsonProperty("OpenStdin")
        private Boolean openStdin;

        @JsonProperty("Labels")
        private Map<String, String> labels;

        @JsonProperty("NetworkDisabled")
        private Boolean networkDisabled;

        @JsonProperty("Image")
        private String image;

        @JsonProperty("MacAddress")
        private String macAddress;

        @JsonProperty("Env")
        private List<String> env;

        @JsonProperty("StdinOnce")
        private Boolean stdinOnce;

        @JsonProperty("AttachStdout")
        private Boolean attachStdout;

        @JsonProperty("WorkingDir")
        private String workingDir;

        @JsonProperty("OnBuild")
        private List<Object> onBuild;

        @JsonProperty("Domainname")
        private String domainname;

        @JsonProperty("AttachStdin")
        private Boolean attachStdin;

        @JsonProperty("Tty")
        private Boolean tty;

        @JsonProperty("Cmd")
        private List<String> cmd;

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public Boolean getAttachStderr() {
            return attachStderr;
        }

        public void setAttachStderr(Boolean attachStderr) {
            this.attachStderr = attachStderr;
        }

        public String getPublishService() {
            return publishService;
        }

        public void setPublishService(String publishService) {
            this.publishService = publishService;
        }

        public String getHostname() {
            return hostname;
        }

        public void setHostname(String hostname) {
            this.hostname = hostname;
        }

        public Boolean getOpenStdin() {
            return openStdin;
        }

        public void setOpenStdin(Boolean openStdin) {
            this.openStdin = openStdin;
        }

        public Map<String, String> getLabels() {
            return labels;
        }

        public void setLabels(Map<String, String> labels) {
            this.labels = labels;
        }

        public Boolean getNetworkDisabled() {
            return networkDisabled;
        }

        public void setNetworkDisabled(Boolean networkDisabled) {
            this.networkDisabled = networkDisabled;
        }

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }

        public String getMacAddress() {
            return macAddress;
        }

        public void setMacAddress(String macAddress) {
            this.macAddress = macAddress;
        }

        public List<String> getEnv() {
            return env;
        }

        public void setEnv(List<String> env) {
            this.env = env;
        }

        public Boolean getStdinOnce() {
            return stdinOnce;
        }

        public void setStdinOnce(Boolean stdinOnce) {
            this.stdinOnce = stdinOnce;
        }

        public Boolean getAttachStdout() {
            return attachStdout;
        }

        public void setAttachStdout(Boolean attachStdout) {
            this.attachStdout = attachStdout;
        }

        public String getWorkingDir() {
            return workingDir;
        }

        public void setWorkingDir(String workingDir) {
            this.workingDir = workingDir;
        }

        public List<Object> getOnBuild() {
            return onBuild;
        }

        public void setOnBuild(List<Object> onBuild) {
            this.onBuild = onBuild;
        }

        public String getDomainname() {
            return domainname;
        }

        public void setDomainname(String domainname) {
            this.domainname = domainname;
        }

        public Boolean getAttachStdin() {
            return attachStdin;
        }

        public void setAttachStdin(Boolean attachStdin) {
            this.attachStdin = attachStdin;
        }

        public Boolean getTty() {
            return tty;
        }

        public void setTty(Boolean tty) {
            this.tty = tty;
        }

        public List<String> getCmd() {
            return cmd;
        }

        public void setCmd(List<String> cmd) {
            this.cmd = cmd;
        }
    }

    public static class RootFS {

        @JsonProperty("Type")
        private String type;

        @JsonProperty("Layers")
        private List<String> layers;

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public List<String> getLayers() {
            return layers;
        }

        public void setLayers(List<String> layers) {
            this.layers = layers;
        }
    }
}